package cn.silver.module.monitor.domain;

import cn.silver.framework.core.utils.DateUtils;
import cn.silver.framework.mybatis.annotation.Table;
import cn.silver.framework.mybatis.annotation.TableField;
import cn.silver.framework.mybatis.enums.SearchEnums;
import cn.silver.framework.mybatis.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@NoArgsConstructor
@Table(name = "log_oper")
@EqualsAndHashCode(callSuper = true)
@Schema(name = "LogOper", title = "系统操作记录", description = "")
public class LogOper extends BaseEntity {

    /**
     * 用户主键
     */
    @Schema(title = "用户主键")
    private String userId;

    /**
     * 登录账号
     */
    @Schema(title = "登录账号")
    @TableField(name = "user_code", searchType = SearchEnums.LIKE)
    private String userCode;

    /**
     * 用户姓名
     */
    @Schema(title = "用户姓名")
    @TableField(name = "user_name", searchType = SearchEnums.LIKE)
    private String userName;

    /**
     * 模块标题
     */
    @Schema(title = "模块编码")
    @TableField(name = "module_code", searchType = SearchEnums.EQ)
    private String moduleCode;

    /**
     * 模块标题
     */
    @Schema(title = "模块标题")
    @TableField(name = "module_name", searchType = SearchEnums.LIKE)
    private String moduleName;

    /**
     * 业务类型
     */
    @Schema(title = "业务类型")
    @TableField(name = "bus_type", searchType = SearchEnums.EQ)
    private String busType;

    @Schema(title = "操作类型")
    @TableField(name = "oper_type", searchType = SearchEnums.EQ)
    private String operType;

    @Schema(title = "设备类型")
    @TableField(name = "device_type", searchType = SearchEnums.EQ)
    private String deviceType;

    /**
     * 主机地址
     */
    @Schema(title = "主机地址")
    private String clientIp;

    /**
     * 客户端编码
     */
    @Schema(title = "客户端编码")
    @TableField(name = "client_code", searchType = SearchEnums.EQ)
    private String clientCode;

    /**
     * 请求URL
     */
    @Schema(title = "请求URL")
    private String reqUrl;

    /**
     * 请求方式
     */
    @Schema(title = "请求方式")
    @TableField(name = "req_method", searchType = SearchEnums.EQ)
    private String reqMethod;

    /**
     * 请求参数
     */
    @Schema(title = "请求参数")
    private String reqParam;

    /**
     * 请求结果
     */
    @Schema(title = "请求结果")
    @TableField(name = "result", searchType = SearchEnums.EQ)
    private String result;

    /**
     * 返回参数
     */
    @Schema(title = "返回参数")
    private String jsonResult;

    /**
     * 操作时间
     */
    @Schema(title = "操作时间")
    @TableField(name = "oper_time", searchType = SearchEnums.BETWEEN)
    @JsonFormat(timezone = DateUtils.TIME_ZONE, pattern = DateUtils.YYYY_MM_DD_HH_MM_SS)
    private Date operTime;

    /**
     * 消耗时间
     */
    @Schema(title = "消耗时间")
    private Long costTime;

    /**
     * 租户编号
     */
    @Schema(title = "租户编号")
    @TableField(name = "tenant_id", searchType = SearchEnums.EQ)
    private String tenantId;
}
